

// setInterval()

let mySetIterval = (handler: () => any, timer: number) => {
    let stop = false;
    
    let run = () => {
        handler()
        loop()
    }

    let loop = () => {
        if ( !stop )
        setTimeout(() => {
            run()
        }, timer);
    }

    let stopLoop = () => {
        stop = true;
    }

    loop();

    return {
        stopLoop
    }
}

export default mySetIterval;